package com.charging.business.media;

import com.charging.business.utils.ToolsUtil;

/**
 * 分省累计实收金额编码信息
 *
 * @author lzj
 */
public class ObuProvEdModel {
    /**
     * 省份区域编码(1,1,cn)
     */
    public byte[] provinceId = new byte[1];

    /**
     * 分省累计实收金额(2-4,3,n)，单位：分
     */
    public byte[] provinceToll = new byte[3];

    public static ObuProvEdModel parse(byte[] buff) {
        int index = 0;
        ObuProvEdModel ret = new ObuProvEdModel();

        index += ToolsUtil.arrcopy(buff, index, ret.provinceId);
        index += ToolsUtil.arrcopy(buff, index, ret.provinceToll);

        return ret;
    }

    public static ObuProvEdModel parse(String strHex) {
        byte[] buff = ToolsUtil.hex2bin(strHex);

        return parse(buff);
    }

    /**
     * 信息解码
     *
     * @return
     */
    public ObuProvModel decoded() {
        ObuProvModel dd = new ObuProvModel();
        dd.provinceId = ToolsUtil.bin2hex(provinceId);
        dd.provinceToll = ToolsUtil.bin2int(provinceToll);

        return dd;
    }
}
